package sctu.edu.java.year2016.team05.zengkun.day20160605.exercise;

import sctu.edu.java.year2016.team05.zengkun.day20160601.listtest.CollectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.ListIterator;

/**
 * Created by mike on 2016/6/5.
 */
public class Ltitor0 {
    public static void main(String[] args) {
        ArrayList<Integer>array=new ArrayList<Integer>();
        Collections.addAll(array, 1, 2, 3, 4, 5, 6);
        System.out.println("集合中的元素：" + array);
        ListIterator<Integer>iterator=array.listIterator();
        boolean hasNext=iterator.hasNext();
        System.out.println("集合是否具有下一个元素："+hasNext);
        boolean hasPrevious=iterator.hasPrevious();
        System.out.println("集合是否具有前一个元素："+hasPrevious);
        int next=iterator.next();
        System.out.println("获得集合的下一个元素："+next);
        int nextindex=iterator.nextIndex();
        System.out.println("获得集合下一个元素的索引："+nextindex);
        int previous =iterator.previous();
        System.out.println("获得集合的前一个元素："+previous);
        int previousindex=iterator.previousIndex();
        System.out.println("获得集合前一个元素的索引："+previousindex);
        iterator.add(7);
        System.out.println("向集合中增加元素7d的集合：" + array);
        iterator.next();
        iterator.set(12);
        System.out.println(array);
        iterator.remove();
        System.out.println(array);
    }
}
